﻿<Window x:Class="SellAvi.Views.WindowAutoReply"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Автоответчик" Height="400" Width="560"
        DataContext="{Binding Mailing, Source={StaticResource Locator}}"
        >
    <DockPanel>

        <DockPanel DockPanel.Dock="Bottom" Background="LightGray" LastChildFill="True" Height="22">
            <ToggleButton DockPanel.Dock="Right" IsChecked="{Binding AutoReplyState}">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/SellAvi;component/Resources/play.png" Width="14"/>
                    <TextBlock Margin="5,0,5,0"><Run Text="Включить автоответчик"/></TextBlock>
                </StackPanel>
            </ToggleButton>
            <!--<Button DockPanel.Dock="Right" Command="{Binding ParseJsonResponseCommand}">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/SellAvi;component/Resources/cube.png" Width="14"/>
                    <TextBlock Margin="5,0,5,0"><Run Text="Json"/></TextBlock>
                </StackPanel>
            </Button>-->
            <Button DockPanel.Dock="Right" Command="{Binding SocketOpenCommand}">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/SellAvi;component/Resources/upload.png" Width="14"/>
                    <TextBlock Margin="5,0,5,0">
                        <TextBlock.Style>
                            <Style TargetType="{x:Type TextBlock}">
                                <Setter Property="Text" Value="Подключиться"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding SocketState}" Value="Open" >
                                        <Setter Property="Text" Value="Отключить"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>
                </StackPanel>
            </Button>
            <Grid>
                <TextBlock Text="{Binding SocketLogging}" FontSize="10" Padding="5"></TextBlock>
            </Grid>


            <DockPanel/>
        </DockPanel>
        <StackPanel DockPanel.Dock="Right" Margin="0,10,0,2" Width="180">


            <Border DockPanel.Dock="Right" Padding="10" BorderThickness="2" Background="LightGray" CornerRadius="5" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="18" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="60" />
                    </Grid.ColumnDefinitions>
                    <Label Grid.Row="0" Grid.Column="0" Padding ="0" Content="Подключение:"/>
                    <Label Grid.Row="1" Grid.Column="0" Padding ="0" Content="Пользователь:"/>
                    <Label Grid.Row="2" Grid.Column="0" Padding ="0" Content="Пакетов:"/>

                    <TextBlock Grid.Column="1" Grid.Row="0" Margin="1" Text="{Binding SocketState, Mode=OneWay}" HorizontalAlignment="Center">
                        <TextBlock.Style>
                            <Style TargetType="{x:Type TextBlock}">
                                <Setter Property="Foreground" Value="Crimson"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding SocketState}" Value="Open" >
                                        <Setter Property="Foreground" Value="Chartreuse"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>
                    <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding ChatUserId, Mode=OneWay}" HorizontalAlignment="Center" FontSize="10" FontWeight="Bold"></TextBlock>
                    <TextBlock Grid.Column="1" Grid.Row="2" HorizontalAlignment="Center">
                            <Run Text="{Binding SocketPacketIn, Mode=OneWay}"></Run>
                            <Run Text="/"></Run>
                            <Run Text="{Binding SocketPacketOut, Mode=OneWay}"></Run>
                    </TextBlock>

                </Grid>
            </Border>
            <Border DockPanel.Dock="Right" Padding="10" BorderThickness="2" Background="LightGray" CornerRadius="5" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="24"/>

                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="60" />
                    </Grid.ColumnDefinitions>
                    <Label Grid.Row="0" Grid.Column="0" Padding ="0" Content="Автоответчик:"/>
                    <Label Grid.Row="1" Grid.Column="0" Padding ="0" Content="Входящих:"/>
                    <Label Grid.Row="2" Grid.Column="0" Padding ="0" Content="Отвечено:"/>
                    <CheckBox Grid.Row="3" Grid.ColumnSpan="2" IsChecked="True" VerticalAlignment="Bottom" IsEnabled="False">не отвечать повторно</CheckBox>

                    <TextBlock Grid.Column="1" Grid.Row="0" Text="On" HorizontalAlignment="Center">
                        <TextBlock.Style>
                            <Style TargetType="{x:Type TextBlock}">
                                <Setter Property="Foreground" Value="DarkGray"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding AutoReplyState}" Value="True" >
                                        <Setter Property="Foreground" Value="Chartreuse"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>
                    <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding IncomingMessages}" HorizontalAlignment="Center"></TextBlock>
                    <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding OutcomingMessages}" HorizontalAlignment="Center"></TextBlock>





                </Grid>
            </Border>
            <Border DockPanel.Dock="Right" Padding="10" BorderThickness="2" Background="LightGray" CornerRadius="5">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" MaxHeight="100"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="150"/>
                    </Grid.ColumnDefinitions>

                    <Label Grid.Column="0" Grid.Row="0" Padding ="0" Content="Последнее сообщение:"/>
                    <TextBlock Grid.Column="0" Grid.Row="1" Text="{Binding LastMessage.body.text}" TextWrapping="WrapWithOverflow" FontStyle="Italic" FontSize="10"></TextBlock>

                </Grid>
            </Border>
        </StackPanel>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="3*" />
                <RowDefinition Height="5" />
                <RowDefinition Height="*"  MinHeight="48"/>
            </Grid.RowDefinitions>

            <DockPanel Grid.Row="0">
                <DockPanel Dock="Bottom"  Height="22" Margin="5,0,5,0"  LastChildFill="False">
                    <StackPanel DockPanel.Dock="Left"  Orientation="Horizontal">
                        <TextBlock HorizontalAlignment="Center" Foreground="DarkGray">
                        <Run Text="новых: "></Run>
                        <Run Text="{Binding ChatInfo.notMyChats, Mode=OneWay}"></Run>
                        <Run Text="   "></Run>
                        </TextBlock>
                        <TextBlock HorizontalAlignment="Center" Foreground="DarkGray">
                        <Run Text="не прочитано: "></Run>
                        <Run Text="{Binding ChatInfo.unreadChats, Mode=OneWay}"></Run>
                        <Run Text="   "></Run>
                        </TextBlock>
                    </StackPanel>

                    <Button DockPanel.Dock="Right" Command="{Binding ReloadChatInfoCommand}" Width="Auto">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/SellAvi;component/Resources/loop.png" Width="14"/>
                            <TextBlock Margin="5,0,5,0"><Run Text="Обновить"/></TextBlock>
                        </StackPanel>
                    </Button>

                </DockPanel>
                <GroupBox Header="Полученые сообщения" Margin="2">
                    <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden">
                        <ItemsControl ItemsSource="{Binding ChatSessionsCollection}" Margin="5">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="14" />
                                            <ColumnDefinition Width="50" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <!--StringFormat=HH:mm:ss-->
                                        <Image Grid.Column="0" Source="/SellAvi;component/Resources/arrow3_e.png"/>
                                        <TextBlock Grid.Column="1" Text="{Binding created, StringFormat={}{0:d}}" FontSize="10" TextAlignment="Center"/>
                                        <TextBlock Grid.Column="2" Text="{Binding lastMessage.body.text}">
                                            <TextBlock.Style>
                                                <Style TargetType="{x:Type TextBlock}">
                                                    <Setter Property="Foreground" Value="Black"/>
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding isRead}" Value="True" >
                                                            <Setter Property="Foreground" Value="DarkGray"/>
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </TextBlock.Style>
                                        </TextBlock>
                                    </Grid>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </ScrollViewer>
                </GroupBox>
            </DockPanel>
            <GridSplitter Grid.Row="1" Height="2" HorizontalAlignment="Stretch" />
            <GroupBox Grid.Row="2" Header="Текст автоответа" Margin="2">
                <!--<TextBox Text="Пожалуйста позвоните мне по указанному в объявлении номеру."></TextBox>-->
                <TextBox Text="{Binding MessageText}" TextWrapping="WrapWithOverflow"></TextBox>
            </GroupBox>
        </Grid>


    </DockPanel>



</Window>
